import axios from '../utils/index';
import { Pat } from '@/typings/request';
const brokersApi = {
    accountList(params: Pat, callback: (T: any) => void) {
        axios
            .get(`/oa/user/getUserList`, {
                params,
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
            })
            .then(res => {
                callback(res.data);
            })
            .catch(err => {
                callback(err);
            });
    },
    accountDetail(userId: string, callback: (T: any) => void) {
        axios
            .get(`/oa/user/getUserDetailByUserId/${userId}`, {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
            })
            .then(res => {
                callback(res.data);
            })
            .catch(err => {
                callback(err);
            });
    },
    accountActive(userId: string, data: Pat, callback: (T: any) => void) {
        axios
            .put(`/oa/user/disable/${userId}`, data, {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
            })
            .then(res => {
                callback(res.data);
            })
            .catch(err => {
                callback(err);
            });
    },
    accountDelete(userId: string, callback: (T: any) => void) {
        axios
            .delete(`/oa/user/delete/${userId}`, {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
            })
            .then(res => {
                callback(res.data);
            })
            .catch(err => {
                callback(err);
            });
    },
};

export default brokersApi;
